package com.smartcat.web.actions;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.smartcat.model.FunctionConfig;
import com.smartcat.service.DeveloperService;
import com.smartcat.web.BaseAction;

@Controller
public class AddFunctionAction extends BaseAction{

	/**
	 * generated version id
	 */
	private static final long serialVersionUID = -2212188293484948670L;
	
	private DeveloperService developerService;
	
	private String beanname;
	
	private String description;
	
	private String functionname;
	
	
	@Autowired
	public void setDeveloperService(DeveloperService developerService) {
		this.developerService = developerService;
	}

	public void setBeanname(String beanname) {
		this.beanname = beanname;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	
	
	
	public void setFunctionname(String functionname) {
		this.functionname = functionname;
	}

	@Override
	public String execute(){
		FunctionConfig function=new FunctionConfig();
		function.setBeanName(beanname);
		function.setFunctionName(functionname);
		function.setDescription(description);
		function.setStartDate(new Date());	
		function.setStatus(0);
		this.developerService.addFunctionConfig(function);
		return SUCCESS;
	}

}
